package com.naiterui.ehp.bs.pharmacist.entity;

import lombok.ToString;

import javax.persistence.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * DocFiles entity. @author MyEclipse Persistence Tools
 */
@Entity
@ToString
@Table(name = "dr_licence")
public class DrLicence implements java.io.Serializable {

    /**
     * 医生文件类型：个人照片
     */
    public static final int DOCTOR_LICENCE_TYPE_AVATAR = 1;

    /**
     * 医生文件类型：工作证
     */
    public static final int DOCTOR_LICENCE_TYPE_EMCARD = 2;

    /**
     * 医生文件类型：医师执业证
     */
    public static final int DOCTOR_LICENCE_TYPE_MEDICAL = 3;

    /**
     * 医生文件类型：身份证
     */
    public static final int DOCTOR_LICENCE_TYPE_IDCARD = 4;

    /**
     * 医生文件类型：职称证书
     */
    public static final int DOCTOR_LICENCE_TYPE_TITLECERTIFICATE = 5;

    /**
     * 医生文件类型：医师资格证
     */
    public static final int DOCTOR_LICENCE_TYPE_QUALIFICATION_CERTIFICATE = 6;

    /**
     * 职业资格证类型 没有版本信息
     */
    public static final int VERSION_TYPE_NO = 0;

    /**
     * 职业资格证类型 新版本
     */
    public static final int VERSION_TYPE_NEW = 1;

    /**
     * 职业资格证类型 旧版本
     */
    public static final int VERSION_TYPE_OLD = 2;

    /**
     * 资质照片类型对应上传图片的类型
     */
    public static final Map<Integer, Integer> TYPE_TO_ATTCHMENT_TYPE = new HashMap<Integer, Integer>() {
        {
            this.put(DOCTOR_LICENCE_TYPE_AVATAR, 1);// 个人照片
            this.put(DOCTOR_LICENCE_TYPE_EMCARD, 2);// 工作证
            this.put(DOCTOR_LICENCE_TYPE_MEDICAL, 3);// 医师执业证
            this.put(DOCTOR_LICENCE_TYPE_IDCARD, 8);// 身份证
            this.put(DOCTOR_LICENCE_TYPE_TITLECERTIFICATE, 9);// 职称证书
            this.put(DOCTOR_LICENCE_TYPE_QUALIFICATION_CERTIFICATE, 10);// 医师资格证
        }
    };

    private static final long serialVersionUID = -6312094809155995832L;

    private Integer id;

    /**
     * 医生ID
     */
    private Long doctorId;

    /**
     * 文件类型1:个人照片,2:工作证,3:职业资格证,4:身份证,5:职称证书
     */
    private Integer type;

    /**
     * 证件版本，0无版本信息，1新版，2旧版
     */
    private int versionType = VERSION_TYPE_NO;

    /**
     * 证件编号
     */
    private String number;

    /**
     * 文件相对路径，如果有多张图逗号分隔，顺序：正，反；照片页，信息页
     */
    private String url;

    private Date createdAt;

    private String createdBy;

    private Date changedAt;

    private String changedBy;

    private Integer version;

    // Constructors

    /**
     * default constructor
     */
    public DrLicence() {
    }

    /**
     * minimal constructor
     */
    public DrLicence(Long doctorId) {
        this.doctorId = doctorId;
    }

    public DrLicence(Long doctorId, Integer type) {
        this.doctorId = doctorId;
        this.type = type;
        this.createdAt = new Date();
        this.createdBy = "system";

    }

    // Property accessors
    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Column(name = "doctor_id", nullable = false)
    public Long getDoctorId() {
        return this.doctorId;
    }

    public void setDoctorId(Long doctorId) {
        this.doctorId = doctorId;
    }

    @Column(name = "type")
    public Integer getType() {
        return this.type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    @Column(name = "number")
    public String getNumber() {
        return this.number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    @Column(name = "url")
    public String getUrl() {
        return this.url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    @Column(name = "created_at", length = 19)
    public Date getCreatedAt() {
        return this.createdAt;
    }

    public void setCreatedAt(Date createdAt) {
        this.createdAt = createdAt;
    }

    @Column(name = "created_by")
    public String getCreatedBy() {
        return this.createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    @Column(name = "changed_at", length = 19)
    public Date getChangedAt() {
        return this.changedAt;
    }

    public void setChangedAt(Date changedAt) {
        this.changedAt = changedAt;
    }

    @Column(name = "changed_by")
    public String getChangedBy() {
        return this.changedBy;
    }

    public void setChangedBy(String changedBy) {
        this.changedBy = changedBy;
    }

    @Column(name = "version_type")
    public int getVersionType() {
        return this.versionType;
    }

    public void setVersionType(int versionType) {
        this.versionType = versionType;
    }

    @Version
    public Integer getVersion() {
        return this.version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

}
